﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EquipmentAndFacility.aspx.cs" Inherits="Catering.yl.EquipmentAndFacility" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="../../../Style/ZHJG/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/zhezhao.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />
    <script type="text/javascript">
        $(document).ready(function () {
            GetDDMDDL();
        });

        function GetDDMDDL()
        {
            $("#txt_PName").empty();
            var classID = $("#hdn_currentClassID").val();
            $.ajax({
                type: "Post",
                url: "EquipmentAndFacility.aspx/GetPName",
                data: "{'classID':'" + classID + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    for (var i = 0; i < data.d.length; i++) {
                        var _item = data.d[i].split(",");
                        $("#txt_PName").append($("<option value='" + _item[0] + "'>" + _item[1] + "</option>"));
                    }
                }
            });
        }

        //显示添加
        function Add() {
            $("#txt_PName").val("");
            $("#txt_Person").val("");
            $("#txt_zhouqi").val("");
            $("#btnEdit").hide();
            $("#btnAdd").show();
            GetDDMDDL();
            divshow("main", "bg");
        }
        //添加数据
        function btn_Add() {
            var txt_PName = $("#txt_PName").val();
            var sel = document.getElementById("Slt1");
            var txt_PType = sel.options[sel.selectedIndex].value;
            var txt_Person = $("#txt_Person").val();
            var txt_zhouqi = $("#txt_zhouqi").val();
            var hdn_useDate = $("#hdn_useDate").val();
            var hdn_currentClassID = $("#hdn_currentClassID").val();


            $.ajax({
                type: "Post",
                url: "EquipmentAndFacility.aspx/Add",
                data: "{'PName':'" + txt_PName + "','PType':'" + txt_PType + "','Person':'" + txt_Person + "','zhouqi':'" + txt_zhouqi + "','hdn_useDate':'" + hdn_useDate + "','hdn_currentClassID':'" + hdn_currentClassID + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",

                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }

        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "EquipmentAndFacility.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_id").val(data.d[0] == null ? "" : data.d[0]);
                    $("#txt_PName").val(data.d[1] == null ? "" : data.d[1]);
                    var sel = document.getElementById("Slt1");
                    sel.options[sel.selectedIndex].text = data.d[2] == null ? "" : data.d[2];
                    $("#txt_Person").val(data.d[3] == null ? "" : data.d[3]);
                    $("#txt_zhouqi").val(data.d[4] == null ? "" : data.d[4]);

                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }
        //修改数据
        function btn_Edit() {
            var txt_PName = $("#txt_PName").val();
            var sel = document.getElementById("Slt1");
            var txt_PType = sel.options[sel.selectedIndex].text;
            var txt_Person = $("#txt_Person").val();
            var txt_zhouqi = $("#txt_zhouqi").val();
            var cid = $("#txt_id").val();

            $.ajax({
                type: "Post",
                url: "EquipmentAndFacility.aspx/Edit",
                data: "{'_id':'" + cid + "','PName':'" + txt_PName + "','PType':'" + txt_PType + "','Person':'" + txt_Person + "','zhouqi':'" + txt_zhouqi + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
    </script>
    <style type="text/css">
        #tb1 tr {
            height: 40px;
        }

        #tb2 tr td {
            height: 40px;
            border-left: 1px solid;
            border-top: 1px solid;
        }

        .auto-style1 {
            width: 50px;
        }
    </style>
</head>
<body style="background-color: #E5F1FD">
    <form id="form1" runat="server">        
        <input type="hidden" id="hdn_useDate" value='<%=Session["useDate"]%>' />
        <input type="hidden" id="hdn_currentClassID" value='<%=Session["ClassID"]%>' />
        <input type="hidden" id="hdn_currentGroupID" value='<%=Session["GroupID"]%>' />
        <asp:HiddenField ID="HidID" runat="server" />
        <div style="margin: auto; width: 370px; height: 500px">
            <table id="tb1" style="width: 100%; font-size: 12px;">
                <tr style="height: 40px">
                    <td>
                        <asp:Label Width="100px" ID="Label2" Visible="false" runat="server" Text="是否零汇报："></asp:Label>

                    </td>
                    <td>
                        <asp:RadioButton ID="EAF_Yes" Visible="false" runat="server" Text="是" GroupName="IsZeroReport" />
                        <asp:RadioButton ID="EAF_No" Visible="false" runat="server" Text="否" GroupName="IsZeroReport" />
                    </td>
                     <td>
                         <asp:Button ID="Button2" runat="server" Text="设备管理台账" OnClick="DMMAccount_Click" CssClass="input_btn_a" Style="float: right" />
                    </td>
                </tr>
                <tr>
                    <td>设备三级管理:</td>
                    <td>
                        类别：<asp:DropDownList ID="ddlDMMAccount" AutoPostBack="true" runat="server" OnSelectedIndexChanged="ddlDMMAccount_SelectedIndexChanged"></asp:DropDownList>
                    </td>
                    <td colspan="2" style="text-align: right">
                        <input id="Button1" type="button" value="新增" onclick="Add()" class="input_btn_a" /></td>
                </tr>
            </table>
            <table cellpadding="0" cellspacing="0" width="100%" style="text-align: center; border-left: 1px solid #8b8888; border-top: 1px solid #8b8888; font-size: 12px;">
                <thead>
                    <tr style="background: url(../../../Images/th_02bg.gif) repeat-x 0px 0px; height: 29px;">
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888;width:30px" class="auto-style1">序号
                        </td>
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">设备名称
                        </td>
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888; width: 50px">类别
                        </td>
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888; width: 50px">负责人
                        </td>
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888; width: 30px">周期
                        </td>
                        <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888; width: 70px">操作
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_Plan" runat="server" OnItemCommand="Rep_Plan_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">
                                    <%#Eval("tempId")%>                                    
                                </td>
                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">
                                    <%#Eval("tempName")%>
                                </td>
                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">
                                    <%#Eval("PType")%>
                                </td>
                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">
                                    <%#Eval("Person")%>
                                </td>
                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">
                                    <%#Eval("zhouqi")%>                                </td>

                                <td style="border-bottom: 1px solid #8b8888; border-right: 1px solid #8b8888">                                    
                                    <%--<img alt="" src="../../../Images/yl/EquipEdit.jpg" style="cursor: pointer;" />--%>
                                    <asp:ImageButton ToolTip="备品备件管理" ID="ImageButton2" runat="server" ImageUrl="../../../Images/yl/EquipEdit.jpg"
                                        CommandArgument='<%#Eval("tempName")%>' CommandName="SpareParts" />
                                    <img alt="编辑" title="编辑" src="../../../Images/file.gif" style="cursor: pointer;" onclick="Edit('<%#Eval("id")%>')" />
                                    <asp:ImageButton ToolTip="删除" ID="ImageButton1" runat="server" ImageUrl="../../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                        CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        </div>
        <!--弹出层-->
        <div id="bg" class="bg">
        </div>
        <div id="main" class="center_div" style="padding: 0px 0px 0px 10px; width: 300px; height: 300px; margin: auto; left: 13%; top: 20%; font-size: 12px">
            <div class="div_0207" style="width: 290px; height: 260px;">
                <h1>
                    <img src="../../../Images/cp_h1_03.gif" />添加设备三级管理</h1>
                <table cellpadding="0" cellspacing="0" style="width: 69%; margin: auto">
                    <tr>
                        <td height="30" class="auto-style6" align="right">设备名称:
                        </td>
                        <td class="auto-style7">
                            <asp:HiddenField ID="txt_id" runat="server" />
                            <select id="txt_PName">
                            </select>
                            <%--<asp:TextBox ID="txt_PName" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>--%>                          
                        </td>
                    </tr>
                    <tr>
                        <td height="30" align="right" class="auto-style8">类别:
                        </td>
                        <td width="105" height="30" align="right">
                            <select id="Slt1" style="width: 110px;" name="D1">
                                <option value="关键设备">关键设备</option>
                                <option value="重要设备">重要设备</option>
                                <option value="一般设备">一般设备</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td height="30" align="right" class="auto-style6">负责人:
                        </td>
                        <td class="auto-style7">
                            <asp:TextBox ID="txt_Person" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td height="30" align="right" class="auto-style8">保养周期:
                        </td>
                        <td>
                            <asp:TextBox ID="txt_zhouqi" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <table width="100%">
                    <tr>
                        <td height="30" align="right" class="auto-style9">
                            <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                            <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                        </td>
                        <td>
                            <input type="button" id="but_Close" onclick='divhidel("main", "bg")' class="input_btn_a"
                                value="关闭" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</body>
</html>
